<template>
  <div class="app-container">
    <!-- 查询区域 -->
    <el-form :model="queryParams" :ref="queryFormRef" inline v-show="showSearch" label-width="auto" @keyup.enter.native="handleQuery">
        <el-form-item label="支付单号" prop="payId">
          <el-input v-model="queryParams.payId" placeholder="支付单号" clearable />
        </el-form-item>
        <!-- <el-form-item label="用户id" prop="userId">
          <el-input-number v-model="queryParams.userId" placeholder="用户id" clearable />
        </el-form-item> -->
        <el-form-item label="关联订单号" prop="orderIds">
          <el-input v-model="queryParams.orderIds" placeholder="关联订单号" clearable />
        </el-form-item>
        <el-form-item label="外部订单流水号" prop="bizPayNo">
          <el-input v-model="queryParams.bizPayNo" placeholder="外部订单流水号" clearable />
        </el-form-item>
        <el-form-item label="支付方式 " prop="payType">
          <lam-dict-select v-model="queryParams.payType" dictCode="pay_type" placeholder="支付方式 " clearable />
        </el-form-item>
        <el-form-item label="支付状态" prop="payStatus">
          <lam-dict-select v-model="queryParams.payStatus" dictCode="pay_status" placeholder="支付状态" clearable />
        </el-form-item>
        <el-form-item label="下单时间" prop="createTimeBegin">
          <el-date-picker clearable v-model="queryParams.createTimeBegin" value-format="yyyy-MM-dd" type="date" placeholder="创建时间">
          </el-date-picker>-
        </el-form-item>
        <el-form-item prop="createTimeEnd">
          <el-date-picker clearable v-model="queryParams.createTimeEnd" value-format="yyyy-MM-dd" type="date" placehodelr="创建时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label-width="0px">
          <el-button type="primary" icon="el-icon-search" @click="handleQuery">搜索</el-button>
          <el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button>
        </el-form-item>
    </el-form>
    <!-- 查询区域-END -->

    <!-- 操作按钮区域 -->
    <div class="tool-bar-btn">
      <el-button type="success" icon="el-icon-tickets" :disabled="single" @click="handleDetail" v-hasPerms="['mall:payInfo:detail']">详情</el-button>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </div>

    <!-- 表格区域 -->
    <selected-info :count="selectedRows.length" :onClearSelected="onClearSelected" />
    <el-table :ref="dataTableRef" v-loading="loading" :data="dataList" stripe border @selection-change="onSelectChange"
          :default-sort = "defaultSort" @sort-change="onSortChange" :row-key="rowKey">
      <el-table-column type="selection" width="55" align="center" fixed="left"/>
      <el-table-column label="支付单号" align="center" prop="payId" sortable="custom" width="200"/>
      <el-table-column label="用户" align="center" prop="userId"  width="100" />
      <el-table-column label="关联订单号" align="center" prop="orderIds" :show-overflow-tooltip="true" width="200" />
      <el-table-column label="外部订单流水号" align="center" prop="bizPayNo"  width="150" />
      <el-table-column label="支付方式 " align="center" prop="payTypeDictText" width="120"/>
      <el-table-column label="支付状态" align="center" prop="payStatusDictText" width="120"/>
      <el-table-column label="支付金额" align="center" prop="payAmount"  width="150" />
      <el-table-column label="下单时间" align="center" prop="createTime" width="180"/>
      <el-table-column label="回调内容" align="center" prop="callbackContent" :show-overflow-tooltip="true" width="150" />
      <el-table-column label="回调时间" align="center" prop="callbackTime" width="180"/>
      <el-table-column label="确认时间" align="center" prop="confirmTime" width="180"/>
      <el-table-column label="操作" align="center" fixed="right" class-name="small-padding fixed-width" width="200">
        <template slot-scope="{row}">
          <el-button type="text" icon="el-icon-tickets" @click="handleDetail(row)">详情</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination v-show="!loading" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"  @pagination="getList" />

    <!-- 添加或修改对话框 -->
    <EditPayInfo ref="formDialog" @ok="getList" />

  </div>
</template>

<script>
import {httpGet, httpDel} from '@/api';
import { IndexListMixin } from '@/components/mixins/IndexListMixin';
import EditPayInfo from './edit';

export default {
  name: "PayInfo",
  mixins:[IndexListMixin],
  components: {
    EditPayInfo,
  },
  data() {
    return {
      //行唯一字段
      rowKey: 'payId',
      defaultOrderBy:'payId',
      // 查询参数
      queryParams: {
        keywords: null,
        payId: null,
        userId: null,
        orderIds: null,
        bizPayNo: null,
        payType: null,
        payStatus: null,
        createTimeBegin: null,
        createTimeEnd: null,
        pageNum: 1,
        pageSize: 10
      },
      url: {
        base: '/mall/payInfo/',
      	list: '/mall/payInfo/list'
      }
    };
  },
  created() {
    this.getList();
  },
  mounted(){
  },
  methods: {
    getList() {
      this.loadData(this.url.list);
    },

    /** 查看详情按钮操作 */
    handleDetail(row) {
      const payId = row.payId || this.selectedRowKeys
      this.$refs.formDialog.toDetail("查看订单支付记录详情", httpGet(this.url.base + payId));
    },

  }
};
</script>
